<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>

<body>
  <div id="vm">
    <cpn2 :cmovies="movies" :cname="name"></cpn2>
  </div>
  <script>
    const cpnC2 = Vue.extend({ //传入对象
      template: `<div>
                  <h1>我是标题2</h1>
                  <p v-for="item in cmovies">{{item}}</p>
                  <p>{{cname}}</p>
                </div>`,
      // props: ['cmovies', 'cname']
      props: {
        cname: {
          type: String,
          default: 'aaaa' //如果data中间的name不存在就会显示aaaa
        },
        cmovies: Array
      }
    })
    var vm = new Vue({
      el: '#vm',
      data: {
        //name: 'Taec',
        movies: ['asd', 'daf', 'dfe', 'dwew']
      },
      components: {
        // cpn1: cpnC1,
        cpn2: cpnC2
      }
    })
  </script>
</body>

</html>